export {}
// 获取范型对象的长度
// infer用于推导范性参数, 通过设置一个不确定的值的泛型U。
// https://juejin.cn/post/6998347146709696519
// infer 表示在 extends 条件语句中待推断的类型变量。
// https://jkchao.github.io/typescript-book-chinese/tips/infer.html

type Length<T extends any[]> = T extends {length: infer U} ? U : never;

type students = []
type tesla = ['tesla', 'model 3', 'model X', 'model Y']
type spaceX = ['FALCON 9', 'FALCON HEAVY', 'DRAGON', 'STARSHIP', 'HUMAN SPACEFLIGHT']

type studentsLength = Length<students> // 0
type teslaLength = Length<tesla>  // expected 4
type spaceXLength = Length<spaceX> // expected 5